<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>一键切换日（夜）间模式</title>
</head>
<body>
    <div class="container light">
        要切换日间或夜间模式请点击屏幕 <br>
    </div>
    
    <style>
    * {
        margin: 0;
        padding: 0;
    }
    
    html,
    body {
        width: 100%;
        height: 100%;
    }
    
    .container {
        width: 100%;
        height: 100%;
    
    }
    
    .light {
        background-color: #f3f3f3;
        color: #333;
    }
    
    .dark {
        background-color: #333;
        color: #f3f3f3;
    }
    </style>
    
    <script>
    let div = document.querySelector('div');
    div.onclick = function () {
        console.log(div.className);
        if (div.className.indexOf('light') != -1) {
            div.className = 'container dark';
        } else {
            div.className = 'container light';
        }
    }
    </script> 
</body>
</html>